<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  <script type="text/javascript" src="js/jquery-1.8.3.js"></script></head>
  <script type="text/javascript">
  $(function(){
  
  /*单个验证  */
  $("input[name=uname]").blur(function(){
  var n=$("input[name=uname]").val();
  $.post("testAjax.action","uname="+n,function(rs){
  $("#message").html(rs);
  })
  })
  
   /*练习  */
 /*  $(function(){
  $("input[name=uname]").blur(function(){
  var m=$("input[]name=uname").val();
  $.post("tt.action","uname="+m,function(js){
  $("#message").html(js);
  })
  })
  }) */
  
  $("input[type=button]").click(function(){
  var name=$("#n").val();
  var pass=$("#p").val();
  $.getJSON("checkLogin.action","user.name="+name+"&user.pass="+pass,function(rs){ 
  if(rs.flag==true){
  $("#info").html(rs.info+"欢迎您:"+rs.user.name);
  }else{
  $("#info").html(rs.info);
  }
  })
  })
  })
  
  /* $("input[type=button]").click(function(){
  var s1=$("#n").val();
  var s2=$("#p").val();
  $.getJSON("checkLogin.action","user.name="+s1+"user.pass="+s2,function(rs){
  if(rs.flag==true){
  $("#info").html(rs.info);
  }else{
   $("#info").html(rs.info);
  }
  })
  }) */
 
  
  </script>
  <body>
  TestName: <input name="uname" type="text"/> &nbsp;<span id="message"></span><br>、
  <form action="" method="post">
  pass:<input name="name" id="n" type="text">
  name:<input name="pass" id="p" type="passworld">
  <input type="button" value="登陆">
  </form>
   <span id="info"></span>
  </body>
</html>
